package StudyCode.summary.zipfile;

import java.io.IOException;
import java.net.URI;
import java.nio.file.*;
import java.util.HashMap;
import java.util.Map;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class UsingTheZIPFilesystem {
	public static void main(String[] args) {
		Map<String, String> attributes = new HashMap<>();
		attributes.put("create", "true");
		try {
			URI zipFile = URI.create("jar:file:/home.zip");
			try (FileSystem zipFileSys = FileSystems.newFileSystem(zipFile, attributes);) {
				Path path = zipFileSys.getPath("docs");
				Files.createDirectory(path);
				try (DirectoryStream<Path> directoryStream =
						     Files.newDirectoryStream(zipFileSys.getPath("/"));) {
					for (Path file : directoryStream) {
						System.out.println(file.getFileName());
					}
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
}
